#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<stdio.h>
using namespace std;
int main()
{
	int x, n;
	int sum = 0;
	scanf("%d %d", &x, &n);
	for (int i = 0; i < n; i++)
	{
		if ((x != 6) && (x != 7))
			sum += 250;
		if (x == 7)
			x = 1;
		else
			x++;
	}
	printf("%d", sum);
	return 0;
}
